home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 November / Pcwk1197.iso / LOTUS / Eng-ins / SMASTERS / APPROACH / CHECKBK.MPR / SCRIPT / ApproachDoc / Main Menu / Body / DeleteBtn.s (.txt) < prev    next >
Null Bytes Alternating  |  1997-01-09  |  5KB  |  76 lines

  1. '++LotusScript Development Environment:2:5:(Options):0:66
  2.  
  3. '++LotusScript Development Environment:2:5:(Forward):0:1
  4. Declare Sub Click(Source As Button, X As Long, Y As Long, Flags As Long)
  5.  
  6. '++LotusScript Development Environment:2:5:(Declarations):0:2
  7.  
  8. '++LotusScript Development Environment:2:2:BindEvents:1:129
  9. Private Sub BindEvents(Byval Objectname_ As String)
  10.     Static Source As BUTTON
  11.     Set Source = Bind(Objectname_)
  12.     On Event Click From Source Call Click
  13. End Sub
  14.  
  15. '++LotusScript Development Environment:2:2:Click:1:12
  16. Sub Click(Source As Button, X As Long, Y As Long, Flags As Long)
  17.     Dim Con As New connection
  18.     Dim Qry As New query
  19.     Dim RS As New resultset
  20.     Dim rval As Integer
  21.     Dim ValidTable, i As Integer
  22.     Dim InputPath As String
  23.     Dim TableNm As String
  24.     
  25.     ValidTable = False
  26.     
  27.     rval = Messagebox( "Permanently remove Approach sample data?",36,"Lotus Approach")
  28.     If rval = 6 Then
  29.         Forall table In CurrentDocument.tables
  30.             For i = 0 To table.NumFields - 1
  31.                 If table.Fieldnames(i) = "SAMPLE" Then
  32.                     ValidTable = True
  33.                     If Instr(1,table.TableName, ":") > 0 Then
  34.                         TableNm = Mid$( table.TableName, 1, Instr(1, table.TableName, ":") - 1)
  35.                     Else
  36.                         TableNm = table.TableName
  37.                     End If
  38.                 End If
  39.             Next
  40.             If ValidTable = True Then
  41.                 If (Con.ConnectTo("dBASE IV")) Then
  42.                     Set Qry.Connection = Con
  43.                     Qry.Sql = "SELECT * FROM """ & table.FullName & """ " & TableNm & " WHERE (" & TableNm & ".SAMPLE = 'Approach Sample Data')"
  44.                     Set RS.Query = Qry
  45.                     Do While RS.Execute = False
  46.                         InputPath = Inputbox$("Couldn't access "+ TableNm +" for import." & "Please enter the full path and database name","Warning")
  47.                         If InputPath = "" Then
  48.                             Exit Sub
  49.                         Else
  50.                             Qry.Tablename = InputPath
  51.                         End If
  52.                     Loop
  53.                 Else
  54.                     Messagebox "Couldn't access "+ TableNm +" for import.  " & "Connection not available"
  55.                     Exit Sub
  56.                 End If
  57.                 
  58.                 Do While RS.numrows <> 0
  59.                     RS.Deleterow
  60.                 Loop
  61.             End If
  62.             ValidTable = False
  63.         End Forall
  64.         
  65.         Set ButtonLbl = CurrentDocument.Main~ Menu.body.DeleteLbl
  66.         Set ButtonDel = CurrentDocument.Main~ Menu.body.DeleteBtn
  67.         Delete ButtonLbl
  68.         Delete ButtonDel
  69.         
  70.         CurrentWindow.SaveChanges
  71.         CurrentWindow.Refresh
  72.         RS.Close
  73.         Con.Disconnect
  74.         
  75.     End If
  76. End Sub